clear
clc
close all
fs = 200;%采样频率
N = 256;%采样点
n = 0:N-1;
t = n/fs;
y = 2+0.5*sin(2*pi*20*t)+2*sin(2*pi*40*t);
x = fft(y,N);
m = abs(x)/(N/2);
f = n*fs/N;%频域
subplot(2,1,1)
plot(f,m);
subplot(2,1,2)
plot(f(1:N/2),m(1:N/2));